package com.baturu.ford.carvin.dal;

import com.baturu.offlineFord.dto.MappingDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * @Author: chenjiahao
 * @Time: 2019/3/12
 */
public interface MappingDAO {

    @Select("select max(id) from ford_epc_parts_detail")
    Integer queryMaxId();

    @Select({"SELECT distinct  epcPartsName,count,dealPartsCode,subGroup,pnc " +
            "from tmp_mapping_20190321" +
            " where  id >#{start}",
            "AND id <= #{end}"
    })
    List<MappingDTO> queryPartsInfo(@Param("start") Integer start,@Param("end") Integer end);

    @Select({"<script>SELECT ifnull(ch,en) des from ford_epc_text " +
            "where textidx in ",
            "<foreach item = 'item' collection = 'c' open = '(' separator=',' close = ')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<String> queryName(@Param("c")Collection<String> c);

    @Select({"<script>INSERT INTO tmp_mapping_out_20190322 (epcPartsName,count,dealPartsCode,subGroup,pnc) values",
            "<foreach item='item' collection= 'dtos' open='(' separator='),(' close=')'>",
            "#{item.epcPartsName},#{item.count},#{item.dealPartsCode},#{item.subGroup},#{item.pnc}",
            "</foreach></script>"})
    void insertImageDTO(@Param("dtos") List<MappingDTO> strings);

}
